﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace zielonka.co.uk.extensions.system
{
    //Description : Convert a double to a string formatted using the culture settings (string representation) passed into the procedure.
    /*
       double test = 120.45;
        string testString = test.ToSpecificCurrencyString("en-US");
     */

    public static partial class DoubleExtensions
    {
        /// <summary>
        /// Format a double using specific culture currency settings.
        /// </summary>
        /// <param name="value">The double to be formatted.</param>
        /// <param name="cultureName">The string representation for the culture to be used, for instance "en-US" for US English.</param>
        /// <returns>The double formatted based on specific culture currency settings.</returns>
        public static string ToSpecificCurrencyString(this double value, string cultureName)
        {
            CultureInfo currentCulture = new CultureInfo(cultureName);
            return (string.Format(currentCulture, "{0:C}", value));
        }
    }
}
